proc writeLog { msg { isDebug false } } {
	if {$isDebug} {
		return [ writeDebug $msg ]
	}
	upvar loggerThread _loggerThread
	if {[ info exists $_loggerThread ] && [ thread::exists $_loggerThread ]} {
		thread::send -async $_loggerThread [ list writeLog $msg ]
	} else {
		puts "[ clock format [ clock seconds ] -format {%Y%m%d %H:%M:%S} ] $msg"
	}
}

proc writeDebug { msg } {
	upvar loggerThread _loggerThread
	if {[ info exists $_loggerThread ] && [ thread::exists $_loggerThread ]} {
		thread::send -async $_loggerThread [ list writeDebug $msg ]
	} else {
		puts "[ clock format [ clock seconds ] -format {%Y%m%d %H:%M:%S} ] debug $msg"
	}
}
